INCLUDE = -I. -I/usr/include -I../../RTR
CFLAGS = -c -Wall
#LDLIBS =   -lglut -lXext -lX11 -lXmu -lXi -lGL -lGLU -lm -lSDL -lSDL_mixer
LDLIBS =   -lglut -lXext -lX11 -lXmu -lXi -lGL -lGLU -lm -lpthread
LDFLAGS =   -L/usr/X11R6/lib -L/usr/lib -L/lib

#program:
#	   	$(CC) $(GCCFLAGS) $(INCLUDE) $(FILENAME).cpp $(LDFLAGS) $(LDLIBS) -o $(FILENAME)

all: RT
	./RT

RT: raytracer.o sphere.o main_ray.o glew.o algfloat.o box.o mesh.o vmatrix.o vshape.o vmesh.o vsphere.o vgrid.o vtorus.o raycaster.o
	gcc -o RT $(LDFLAGS) $(LDLIBS) raytracer.o sphere.o main_ray.o glew.o algfloat.o box.o mesh.o vmatrix.o vshape.o vmesh.o vsphere.o vgrid.o vtorus.o raycaster.o

raytracer.o: raytracer.cpp raytracer.h algfloat.h dynarray.h light.h raycaster.h object.h ray.h sphere.h
	gcc $(CFLAGS) raytracer.cpp $(INCLUDE)

sphere.o: sphere.cpp sphere.h algfloat.h ray.h object.h
	gcc $(CFLAGS) sphere.cpp $(INCLUDE)

main_ray.o: main_ray.cpp glheader.h sphere.h raytracer.h raycaster.h light.h glew.h object.h
	gcc $(CFLAGS) main_ray.cpp $(INCLUDE)

glew.o: glew.c glew.h
	gcc $(CFLAGS) glew.c $(INCLUDE)

algfloat.o: algfloat.c algfloat.h
	gcc $(CFLAGS) algfloat.c $(INCLUDE)

box.o: box.cpp box.h object.h ray.h
	gcc $(CFLAGS) box.cpp $(INCLUDE)

mesh.o: mesh.cpp mesh.h object.h ray.h
	gcc $(CFLAGS) mesh.cpp $(INCLUDE)

raycaster.o: raycaster.h ray.h algfloat.h
	gcc $(CFLAGS) raycaster.cpp $(INCLUDE)

#files from RTR

vmatrix.o: ../../RTR/vmatrix.cpp ../../RTR/vmatrix.h
	cp ../../RTR/vmatrix.cpp ./
	gcc $(CFLAGS) vmatrix.cpp $(INCLUDE)
	rm -f vmatrix.cpp

vshape.o: ../../RTR/vshape.cpp ../../RTR/vshape.h ../../RTR/glheader.h
	cp ../../RTR/vshape.cpp ./
	gcc $(CFLAGS) vshape.cpp $(INCLUDE)
	rm -f vshape.cpp

vmesh.o: ../../RTR/vmesh.cpp ../../RTR/vmesh.h ../../RTR/glheader.h ../../RTR/vshape.h
	cp ../../RTR/vmesh.cpp ./
	gcc $(CFLAGS) vmesh.cpp $(INCLUDE)
	rm -f vmesh.cpp

vsphere.o: ../../RTR/vsphere.cpp ../../RTR/vshape.h ../../RTR/VSphere.h ../../RTR/vgrid.h 
	cp ../../RTR/vsphere.cpp ./
	gcc $(CFLAGS) vsphere.cpp $(INCLUDE)
	rm -f vsphere.cpp

vgrid.o: ../../RTR/vgrid.cpp ../../RTR/vgrid.h ../../RTR/vshape.h ../../RTR/glheader.h
	cp ../../RTR/vgrid.cpp ./
	gcc $(CFLAGS) vgrid.cpp $(INCLUDE)
	rm -f vgrid.cpp

vtorus.o: ../../RTR/vtorus.cpp ../../RTR/vtorus.h ../../RTR/vgrid.h ../../RTR/vshape.h
	cp ../../RTR/vtorus.cpp ./
	gcc $(CFLAGS) vtorus.cpp $(INCLUDE)
	rm -f vtorus.cpp

clean:
	rm -f RT raytracer.o sphere.o main_ray.o glew.o algfloat.o box.o mesh.o vmatrix.o vshape.o vmesh.o vsphere.o vgrid.o vtorus.o raycaster.o
